package jam.network.message;

import jam.network.NetworkController;
import java.util.Scanner;
import java.lang.String;

public class ResponseLock extends ServerResponse {

	public static void process(String msg) {
		Scanner s = new Scanner( msg );
		s.useDelimiter(":");

		//skip keyword
		s.next();
	 
		//get channel name from original message
		int id = s.nextInt();
		String orig = NetworkController.sent.get(id);
		Scanner msgScan = new Scanner(orig).useDelimiter(":");
		msgScan.next();
		msgScan.next();
		String channel = msgScan.next();
		String l;
		if (msgScan.next() == "TRUE")
			l = "locked";
		else
			l = "unlocked";

		//clean up hashmap
		NetworkController.sent.remove(id);
	
		String result = s.next();

		if ( result.equalsIgnoreCase("TRUE") )
			System.out.println(channel + " " + l);
		else
			System.out.println("Failed to " + l + " " + channel);
	}

}